package com.hss.common.utils;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

import java.io.File;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CommonUtil {
	private static final String TAG = CommonUtil.class.getSimpleName();

	/**
	 * 
	 * @Title: isRunningForeground
	 * @date 2015-3-4 上午10:33:33
	 * @author (黄赛赛)
	 * @Description: TODO(判断应用是否前台运行)
	 * @param @param context
	 * @param @return 设定文件
	 * @return boolean 返回类型
	 * @throws < uses-permission android:name =“android.permission.GET_TASKS” />
	 */
	public static boolean isRunningForeground(Context context) {
		ActivityManager am = (ActivityManager) context
				.getSystemService(Context.ACTIVITY_SERVICE);
		List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
		if (!tasks.isEmpty()) {
			ComponentName topActivity = am.getRunningTasks(1).get(0).topActivity;
			String currentPackageName = topActivity.getPackageName();
			if (!TextUtils.isEmpty(currentPackageName)
					&& currentPackageName.equals(context.getPackageName())) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 判断手机是否处理睡眠
	 * 
	 * @param context
	 * @return
	 */
	public static boolean isSleeping(Context context) {
		KeyguardManager kgMgr = (KeyguardManager) context
				.getSystemService(Context.KEYGUARD_SERVICE);
		boolean isSleeping = kgMgr.inKeyguardRestrictedInputMode();
		Log.d(TAG, isSleeping ? "手机睡眠中.." : "手机未睡眠...");
		return isSleeping;
	}

	/**
	 * 
	 * @Title: restartApplication
	 * @date 2015-3-4 上午11:19:42
	 * @author (黄赛赛)
	 * @Description: TODO(重启应用)
	 * @param @param context 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public static void restartApplication(Context context) {
		final Intent intent = context.getPackageManager()
				.getLaunchIntentForPackage(context.getPackageName());
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		context.startActivity(intent);
	}

	/**
	 * 
	 * @ 功能 获取sim 序列号
	 * 
	 * @param mContext
	 * @return sim 序列号
	 * @作者 2014-5-18 /黄赛赛
	 */
	public static String getSimMumber(Context mContext) {
		String sim = null;
		TelephonyManager mTelephonyMgr = (TelephonyManager) mContext
				.getSystemService(Context.TELEPHONY_SERVICE);
		sim = mTelephonyMgr.getSubscriberId();
		mContext = null;
		mTelephonyMgr = null;
		return sim;
	}

	/**
	 * 安装apk
	 * 
	 * @param context
	 * @param file
	 */
	public static void installApk(Context context, File file) {
		Intent intent = new Intent();
		intent.setAction("android.intent.action.VIEW");
		intent.addCategory("android.intent.category.DEFAULT");
		intent.setType("application/vnd.android.package-archive");
		intent.setData(Uri.fromFile(file));
		intent.setDataAndType(Uri.fromFile(file),
				"application/vnd.android.package-archive");
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		context.startActivity(intent);

	}

	/**
	 * 判断是否为手机
	 * 
	 * @param context
	 * @return
	 * @author wangjie
	 */
	public static boolean isPhone(Context context) {
		TelephonyManager telephony = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);
		int type = telephony.getPhoneType();
		if (type == TelephonyManager.PHONE_TYPE_NONE) {
			Log.i(TAG, "Current device is Tablet!");
			return false;
		} else {
			Log.i(TAG, "Current device is phone!");
			return true;
		}
	}

	/**
	 * 获取设备id（IMEI）
	 * 
	 * @param context
	 * @return
	 * @author wangjie
	 */
	@TargetApi(Build.VERSION_CODES.CUPCAKE)
	public static String getDeviceIMEI(Context context) {
		String deviceId;
		if (isPhone(context)) {
			TelephonyManager telephony = (TelephonyManager) context
					.getSystemService(Context.TELEPHONY_SERVICE);
			deviceId = telephony.getDeviceId();
		} else {
			deviceId = Settings.Secure.getString(context.getContentResolver(),
					Settings.Secure.ANDROID_ID);

		}
		Log.d(TAG, "当前设备IMEI码: " + deviceId);
		return deviceId;
	}

	/**
	 * 获取当前应用程序的版本号
	 * 
	 * @param context
	 * @return
	 * @author wangjie
	 */
	public static String getAppVersion(Context context) {
		String version = "0";
		try {
			version = context.getPackageManager().getPackageInfo(
					context.getPackageName(), 0).versionName;
		} catch (NameNotFoundException e) {
			e.printStackTrace();
			Log.e(TAG, "getAppVersion", e);
		}
		Log.d(TAG, "该应用的版本号: " + version);
		return version;
	}

	/**
	 * 获取版本号(内部识别号)
	 * @param context
	 * @return
     */
	public static int getAppVersionCode(Context context)//
	{
		try {
			PackageInfo pi=context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
			return pi.versionCode;
		} catch (NameNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}
	}
	/**
	 * 使用Properties来保存设备的信息和错误堆栈信息
	 */
	private static final String VERSION_NAME = "versionName";
	private static final String VERSION_CODE = "versionCode";
	private static final String STACK_TRACE = "STACK_TRACE";

	/**
	 * 收集设备信息
	 * 
	 * @param context
	 */
	public static Properties collectDeviceInfo(Context context) {
		Properties mDeviceCrashInfo = new Properties();
		try {
			// Class for retrieving various kinds of information related to the
			// application packages that are currently installed on the device.
			// You can find this class through getPackageManager().
			PackageManager pm = context.getPackageManager();
			// getPackageInfo(String packageName, int flags)
			// Retrieve overall information about an application package that is
			// installed on the system.
			// public static final int GET_ACTIVITIES
			// Since: API Level 1 PackageInfo flag: return information about
			// activities in the package in activities.
			PackageInfo pi = pm.getPackageInfo(context.getPackageName(),
					PackageManager.GET_ACTIVITIES);
			if (pi != null) {
				// public String versionName The version name of this package,
				// as specified by the <manifest> tag's versionName attribute.
				mDeviceCrashInfo.put(VERSION_NAME,
						pi.versionName == null ? "not set" : pi.versionName);
				// public int versionCode The version number of this package,
				// as specified by the <manifest> tag's versionCode attribute.
				mDeviceCrashInfo.put(VERSION_CODE, pi.versionCode);
			}
		} catch (NameNotFoundException e) {
			Log.e(TAG, "Error while collect package info", e);
		}
		// 使用反射来收集设备信息.在Build类中包含各种设备信息,
		// 例如: 系统版本号,设备生产商 等帮助调试程序的有用信息
		// 返回 Field 对象的一个数组，这些对象反映此 Class 对象所表示的类或接口所声明的所有字段
		Field[] fields = Build.class.getDeclaredFields();
		for (Field field : fields) {
			try {
				// setAccessible(boolean flag)
				// 将此对象的 accessible 标志设置为指示的布尔值。
				// 通过设置Accessible属性为true,才能对私有变量进行访问，不然会得到一个IllegalAccessException的异常
				field.setAccessible(true);
				mDeviceCrashInfo.put(field.getName(), field.get(null));
				// if (DEBUG) {
				// Log.d(TAG, field.getName() + " : " + field.get(null));
				// }
			} catch (Exception e) {
				Log.e(TAG, "Error while collect crash info", e);
			}
		}

		return mDeviceCrashInfo;
	}

	/**
	 * 收集设备信息
	 * 
	 * @param context
	 * @return
	 */
	public static String collectDeviceInfoStr(Context context) {
		Properties prop = collectDeviceInfo(context);
		Set deviceInfos = prop.keySet();
		StringBuilder deviceInfoStr = new StringBuilder("{\n");
		for (Iterator iter = deviceInfos.iterator(); iter.hasNext();) {
			Object item = iter.next();
			deviceInfoStr.append("\t\t\t" + item + ":" + prop.get(item)
					+ ", \n");
		}
		deviceInfoStr.append("}");
		return deviceInfoStr.toString();
	}

	/**
	 * 
	 * @ 功能 获取项目的路径
	 * 
	 * @param mContext
	 * @return @ 作者 2014-5-21 / 黄赛赛
	 */
	/*
	 * public static String getCurProjectDir(Context mContext) { if (mContext ==
	 * null) return null; String path = null; File file = null; if
	 * (sdCardIsAvailable()) { String appName =
	 * mContext.getResources().getString( R.string.app_name); path =
	 * FileUtils.getSDRoot() + appName; file = new File(path); path +=
	 * File.separator; } else { file = mContext.getFilesDir(); if (file != null)
	 * { path = file.getAbsolutePath() + File.separator; } }
	 * 
	 * if (file != null) { if (!file.exists() || !file.isDirectory()) { if
	 * (file.mkdir()) { if (ConstInt.isDebug)
	 * LogUtils.e("********make ProjectDir ok ********"); } else { if
	 * (ConstInt.isDebug) LogUtils.e("********make ProjectDir fail ********"); }
	 * } } mContext = null; file = null; return path; }
	 */
	/**
	 * 
	 * @ 功能
	 * 
	 * @param mContext
	 * @param name
	 *            路径
	 * @return @ 作者 2014-5-21 / 黄赛赛
	 */
	/*
	 * public static String getDirByProject(Context mContext, String name) { if
	 * (sdCardIsAvailable()) { String path = getCurProjectDir(mContext) + name;
	 * File file = new File(path); if (file != null) { if (!file.exists() ||
	 * !file.isDirectory()) { if (file.mkdirs()) { if (ConstInt.isDebug)
	 * LogUtils.e("********make ProjectDir ok ********"); } else { if
	 * (ConstInt.isDebug) LogUtils.e("********make ProjectDir fail ********"); }
	 * } } path += File.separator; return path; } else { return null; } }
	 */

	/**
	 * 
	 * @ 功能
	 * 
	 * @param activity
	 * @return @ 作者 2014-5-21 / 黄赛赛
	 */
	public static DisplayMetrics getDisplayMetrics(Activity activity) {
		if (activity == null) {
			return null;
		}
		DisplayMetrics metrics = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
		return metrics;
	}

	/**
	 * 获取版本号
	 * 
	 * @return 当前应用的版本号
	 */
	/*
	 * public static String getVersion(Context mContext) { try { PackageManager
	 * manager = mContext.getPackageManager(); PackageInfo info =
	 * manager.getPackageInfo( mContext.getPackageName(), 0); String version =
	 * info.versionName; return version; } catch (Exception e) {
	 * e.printStackTrace(); return
	 * mContext.getString(R.string.can_not_find_version_name); } }
	 */

	/**
	 * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
	 */
	public static int dip2px(Context context, float dpValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (dpValue * scale + 0.5f);
	}

	/**
	 * dp转px
	 * 
	 * @param res
	 *            android.content.res.Resources
	 * @param dp
	 * @return
	 */
	public static int dpToPx(Resources res, int dp) {
		return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
				res.getDisplayMetrics());
	}

	/**
	 * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
	 */
	public static int px2dip(Context context, float pxValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (pxValue / scale + 0.5f);
	}

	/**
	 * 判断手机号码是否有误
	 * 
	 * 
	 */

	public static boolean checkPhoneNum(String phoneNum) {
		if (phoneNum == null || phoneNum.length() != 11) {
			return false;
		}
		String regExp = "^((13[0-9])|(147)|(15[^4,\\D])|(18[0-9]))|(17[0-9])\\d{8}$";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(phoneNum);
		if (m.find()) {
			return true;
		}
		return false;
	}

	// /**
	// * 判断电话号码是否有误
	// *
	// *
	// */
	// @SuppressLint("NewApi")
	// public static boolean checkTelNum(String telNum) {
	// if (telNum == null || telNum.isEmpty()) {
	// return false;
	// }
	// String regex = "^0(10|2[0-5789]|\\d{3})\\d{7,8}$";
	// if (telNum.matches(regex)) {
	// return true;
	// } else {
	// return false;
	// }
	// }

	/**
	 * 
	 * @ 功能 判断邮箱地址是否正确
	 * 
	 * @param mailNum
	 * @return @ 作者 2014年8月15日 / 郭张宇
	 */
	@SuppressLint("NewApi")
	public static boolean checkMailNum(String mailNum) {
		if (mailNum == null || mailNum.isEmpty()) {
			return false;
		}
		String regex = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
		if (mailNum.matches(regex)) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 
	 * @ 功能 判断url地址是否正确
	 * 
	 * @param url
	 * @return @ 作者 2014年8月15日 / 郭张宇
	 */
	@SuppressLint("NewApi")
	public static boolean checkUrlStr(String url) {
		if (url == null || url.isEmpty()) {
			return false;
		}
		String regex = "[a-zA-z]+://[^\\s]*";
		if (url.matches(regex)) {
			return true;
		} else {
			return false;
		}
	}

	// 验证是否为数字
	@SuppressLint("NewApi")
	public static boolean checkPriceNum(String priceNum) {
		if (priceNum == null || priceNum.isEmpty()) {
			return false;
		}
		String regex = "^[0-9]+(\\.[0-9]{1,2})?$";
		if (priceNum.matches(regex)) {
			return true;
		} else {
			return false;
		}
	}

	// 价格判断小数位的值
	public static String checkPriceDecimalPoint(String priceNum) {
		if (priceNum == null)
			return "0";
		BigDecimal aa = new BigDecimal(priceNum);
		DecimalFormat df = new DecimalFormat("0.##");
		priceNum = df.format(aa);
		return priceNum;
	}

	/**
	 * 
	 * @ 功能 gps 打开
	 * 
	 * @param context
	 * @return @ 作者 2014-8-27 / 黄赛赛
	 */
	public static boolean isGPSEnable(Context context) {
		String str = Settings.Secure.getString(context.getContentResolver(),
				Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
		context = null;
		if (str != null) {
			return str.contains("gps");
		} else {
			return false;
		}
	}

	/**
	 * 
	 * @ 功能 关闭gps
	 * 
	 * @param context
	 *            @ 作者 2014-8-27 / 黄赛赛
	 */
	// public static void closeGps(Context context) {
	// Intent gpsIntent = new Intent();
	// gpsIntent.setClassName("com.android.settings",
	// "com.android.settings.widget.SettingsAppWidgetProvider");
	// gpsIntent.addCategory("android.intent.category.ALTERNATIVE");
	// gpsIntent.setData(Uri.parse("custom:3"));
	// try {
	// PendingIntent.getBroadcast(context, 0, gpsIntent, 0).send();
	// } catch (CanceledException e) {
	// e.printStackTrace();
	// LogUtils.e(e.getMessage());
	// }
	// ToastUtil.showToast(context, "关闭gps", false);
	//
	// }

	/**
	 * 
	 * @ 功能
	 * 
	 * @param context
	 * @param packageName
	 * @return @ 作者 2014-8-28 / 黄赛赛
	 */
	public static boolean isAviliblePackage(Context context, String packageName) {
		final PackageManager packageManager = context.getPackageManager();
		// 获取所有已安装程序的包信息
		List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
		for (int i = 0; i < pinfo.size(); i++) {
			if (pinfo.get(i).packageName.equalsIgnoreCase(packageName))
				return true;
		}
		return false;
	}

	/**
	 * 检测该包名所对应的应用是否存在
	 * 
	 * @param packageName
	 * @return
	 */
	public static boolean checkPackage(Context context, String packageName) {
		if (packageName == null || "".equals(packageName))
			return false;
		try {
			context.getPackageManager().getApplicationInfo(packageName,
					PackageManager.GET_UNINSTALLED_PACKAGES);
			return true;
		} catch (NameNotFoundException e) {
			return false;
		}
	}

	/**
	 * 
	 * @ 功能 隐藏键盘 @ 作者 2014-9-5 / 黄赛赛
	 */
	public static void hideKeyboard(Activity activity) {
		InputMethodManager imm = (InputMethodManager) activity
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		if (imm != null && activity.getCurrentFocus() != null
				&& activity.getCurrentFocus().getWindowToken() != null) {
			imm.hideSoftInputFromWindow(activity.getCurrentFocus()
					.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
		}

	}

	/**
	 * 
	 * 弹出键盘
	 */

	public static void showKeyBoard(final Context mContext, final EditText et) {
		et.setFocusable(true);
		et.setFocusableInTouchMode(true);
		et.requestFocus();
		Timer timer = new Timer();
		timer.schedule(new TimerTask() {
			public void run() {
				InputMethodManager inputManager = (InputMethodManager) mContext
						.getSystemService(Context.INPUT_METHOD_SERVICE);
				inputManager.showSoftInput(et, 0);

			}
		}, 0);
	}

	/**
	 * 隐藏软键盘
	 */
	@TargetApi(Build.VERSION_CODES.CUPCAKE)
	public static void hideSoftInput(Activity activity) {
		View view = activity.getWindow().peekDecorView();
		if (view != null) {
			InputMethodManager inputmanger = (InputMethodManager) activity
					.getSystemService(Context.INPUT_METHOD_SERVICE);
			inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
		}
	}

	/**
	 * 隐藏软键盘
	 */
	@TargetApi(Build.VERSION_CODES.CUPCAKE)
	public static void hideSoftInput(Context context, EditText edit) {
		edit.clearFocus();
		InputMethodManager inputmanger = (InputMethodManager) context
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0);
	}

	/**
	 * 显示软键盘
	 */
	@TargetApi(Build.VERSION_CODES.CUPCAKE)
	public static void showSoftInput(Context context, EditText edit) {
		edit.setFocusable(true);
		edit.setFocusableInTouchMode(true);
		edit.requestFocus();
		InputMethodManager inputManager = (InputMethodManager) context
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		inputManager.showSoftInput(edit, 0);
	}

	@TargetApi(Build.VERSION_CODES.CUPCAKE)
	public static void toggleSoftInput(Context context, EditText edit) {
		edit.setFocusable(true);
		edit.setFocusableInTouchMode(true);
		edit.requestFocus();
		InputMethodManager inputManager = (InputMethodManager) context
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
	}

	/**
	 * 回到home，后台运行
	 * 
	 * @param context
	 */
	public static void goHome(Context context) {
		Log.d(TAG, "返回键回到HOME，程序后台运行...");
		Intent mHomeIntent = new Intent(Intent.ACTION_MAIN);

		mHomeIntent.addCategory(Intent.CATEGORY_HOME);
		mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
				| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
		context.startActivity(mHomeIntent);
	}

	/**
	 * 
	 * @Title: checkNickName
	 * @Description: TODO(校验昵称)
	 * @param @param name
	 * @param @return 设定文件
	 * @return boolean 返回类型 @ 作者　2014-12-1 / 黄赛赛
	 * @throws
	 */
	@SuppressLint("NewApi")
	public static boolean checkNickName(String name) {
		String regex = "^[a-zA-Z0-9_\u4e00-\u9fa5]+$";
		if (name.matches(regex)) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 
	 * @Title: isHanzi2
	 * @date 2015-3-18 下午3:44:23
	 * @author (黄赛赛)
	 * @Description: TODO(判断是否汉字)
	 * @param @param str 设定文件
	 * @return void 返回类型
	 * @throws
	 */
	public void isHanzi2(String str) {
		String regEx = "[\u4e00-\u9fa5]";
		Pattern p = Pattern.compile(regEx);
		Matcher m = p.matcher(str);
		while (m.find()) {
			System.out.print(m.group(0) + "");
		}
	}

	// 根据Unicode编码完美的判断中文汉字和符号
	public static boolean isChinese(char c) {
		Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
		if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
				|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
				|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
				|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
				|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
				|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
				|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION) {
			return true;
		}
		return false;
	}

	
	/**
	 * 
	 * @Title: getRTFFileIntent 
	 * @date 2015-4-13 上午9:08:21 
	 * @author (黄赛赛)  
	 * @Description: TODO(  thinkfree office 打开rtf文件) 
	 * @param param 文件路径
	 * @return    设定文件 
	 * @return Intent    返回类型 
	 * @throws
	 */
	public static Intent getRTFFileIntent(String param)

	{

		Intent intent = new Intent("android.intent.action.VIEW");

		intent.addCategory("android.intent.category.DEFAULT");

		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

		Uri uri = Uri.fromFile(new File(param));

		intent.setDataAndType(uri, "/rtf");

		return intent;

	}
	
	/**
	 * 
	 * @Title: isEmptyArr 
	 * @date 2015-6-18 下午10:14:56 
	 * @author (黄赛赛)  
	 * @Description: TODO(数组是否为空) 
	 * @param arr
	 * @return    设定文件 
	 * @return boolean    返回类型 
	 * @throws
	 */
	public static boolean isEmptyArr(Object[] arr){
		boolean flag = true;
		if (arr != null && arr.length > 0){
			flag = false;;
		}
		return flag;
	}
	

	
	/**
	 * 
	 * @Title: isEmptyMap 
	 * @date 2015-6-18 下午10:15:12 
	 * @author (黄赛赛)  
	 * @Description: TODO(map是否为空) 
	 * @param map
	 * @return    设定文件 
	 * @return boolean    返回类型 
	 * @throws
	 */
	public static boolean isEmptyMap(Map<Object,Object> map){
		boolean flag = true;
		if (map != null && map.size() > 0){
			flag = false;
		}
		return flag;
	}
	 
	
	/**
	 * 
	 * @Title: getAppId 
	 * @date 2015-7-16 上午10:22:43 
	 * @author (黄赛赛)  
	 * @Description: TODO(获取32位的appid 不够补0) 
	 * @param mContext
	 * @return    设定文件 
	 * @return String    返回类型 
	 * @throws
	 */
	public static String getAppId(Context mContext){
		String deviceId = getDeviceIMEI(mContext);
		StringBuilder sb = new StringBuilder();
		sb.append(deviceId);
		for  (int i =deviceId.length() ,size = 32; i <size; i++ ){
			sb.append("0");
		}
		deviceId = sb.toString();
		sb.delete(0, sb.length());
		sb = null;
		return deviceId;
	}
}
